function setCookie(name, value, expires) {
  if (expires) {
    document.cookie = `${name}=${value};expires = ${expires} `
  } else {
    document.cookie = ` ${name} = ${value};`
  }
}

function getTimeString(timemillisDiffer) {
  const newtimestamp = (new Date().getTime() - 8 * 3600 * 1000 + timemillisDiffer)
  return new Date(newtimestamp).toString
}

function deleteCookie(name) {
  document.cookie = `${name} = die;expires = ${getTimeString(-1)}`
}

function getCookie(name) {
  const arr = document.cookie.split(`; `)
  for (let i = 0; i < arr.length; i++) {
    const kv = arr[i].split(`=`)
    if (kv[0] === name) {
      return kv[1]
    }
  }
}